package com.meng.menggaga.ui;

import android.support.v4.app.Fragment;

import com.github.johnpersano.supertoasts.SuperActivityToast;
import com.github.johnpersano.supertoasts.SuperToast;
import com.meng.menggaga.R;

public abstract class BaseFragment extends Fragment {

    @Override
    public void onResume() {
        super.onResume();
    }

    protected final void overridePendingTransition() {
        getActivity().overridePendingTransition(R.anim.in_from_right, R.anim.out_from_left);
    }

    protected void showStandardToast(int resId) {
        showStandardToast(getString(resId));
    }

    /**
     * 显示标准的toast
     * 
     * @param str
     */
    protected void showStandardToast(String text) {
        SuperActivityToast superToast =
                new SuperActivityToast(getActivity(), SuperToast.Type.STANDARD);
        superToast.setAnimations(SuperToast.Animations.SCALE);
        superToast.setDuration(SuperToast.Duration.SHORT);
        superToast.setBackground(SuperToast.Background.BLUE);
        superToast.setTextSize(SuperToast.TextSize.MEDIUM);
        superToast.setText(text);
        superToast.show();
    }

    /**
     * 显示进度条
     * 
     * @param text
     * @return
     */
    protected SuperActivityToast showProgressToast(String text) {
        SuperActivityToast superToast =
                new SuperActivityToast(getActivity(), SuperToast.Type.PROGRESS_HORIZONTAL);
        superToast.setAnimations(SuperToast.Animations.SCALE);
        superToast.setDuration(SuperToast.Duration.SHORT);
        superToast.setBackground(SuperToast.Background.BLUE);
        superToast.setTextSize(SuperToast.TextSize.MEDIUM);
        superToast.setText(text);
        superToast.show();
        return superToast;
    }

}
